package com.lc.rongzecaifu.conn;

import android.util.Log;

import com.google.gson.Gson;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

import java.util.List;

/**
 * Created by Administrator on 4/26/2016.
 */
@HttpInlet("user/borrow_in")
public class JsonBorrowout extends HYAsyGet<JsonBorrowout.Info> {
    public String access_token;
    public int p;

    public String uid;
    public String show_type;
    public String start_time;
    public String end_time;

    //    String p,
    public JsonBorrowout(String access_token, String uid, String start_time, String end_time, String show_type, int p, AsyCallBack<Info> asyCallBack) {
        super(asyCallBack);
        this.access_token = access_token;
        this.p = p;
        this.uid = uid;
        this.show_type = show_type;
        this.start_time = start_time;
        this.end_time = end_time;
    }


    @Override
    protected Info parser(JSONObject object) {
        Log.d(object.toString(), "asdkljf");
      /*  Log.d(object.toString(),"asdkljf");
        Info info = null;
        if (object.optString("status").equals("1")) {
            info = new Info();
            info.total_money = object.optString("total_money");
            info.total_num = object.optString("total_num");

            Info.Page page = new Info.Page();
            JSONObject jsonObject = object.optJSONObject("page");
            page.nowPage = Integer.parseInt(jsonObject.optString("nowPage"));
            page.totalPages = Integer.parseInt(jsonObject.optString("totalPages"));
            page.pageSize = Integer.parseInt(jsonObject.optString("pageSize"));
            page.totalRows = Integer.parseInt(jsonObject.optString("totalRows"));
            info.page = page;
            JSONArray array = object.optJSONArray("list");
            List<Info.ListContent> list = new ArrayList();
            for (int i = 0; i < array.length(); i++) {
                JSONObject object1 = array.optJSONObject(i);
                Info.ListContent listContent = new Info.ListContent();
                listContent.investor_all = object1.optString("investor_all");
                listContent.id = object1.optString("id");
                listContent.borrow_id = object1.optString("borrow_id");
                listContent.investor_capital = object1.optString("investor_capital");
                listContent.investor_interest = object1.optString("investor_interest");
                listContent.receive_capital = object1.optString("receive_capital");
                listContent.receive_interest = object1.optString("receive_interest");
                listContent.invest_time = object1.optString("invest_time");
                listContent.borrow_name = object1.optString("borrow_name");
                listContent.borrow_money = object1.optString("borrow_money");
                listContent.borrow_interest_rate = object1.optString("borrow_interest_rate");
                listContent.borrow_duration = object1.optString("borrow_duration");
                listContent.repayment_type = object1.optString("repayment_type");
                listContent.borrow_status = object1.optString("borrow_status");
                listContent.has_pay = object1.optString("has_pay");
                listContent.borrow_user = object1.optString("borrow_user");
                listContent.total = object1.optString("total");
                listContent.back = object1.optString("back");
                listContent.receive_money = object1.optString("receive_money");
                listContent.unreceive_money = object1.optString("unreceive_money");
                listContent.unreceive_interest = object1.optString("unreceive_interest");
                listContent.repayment_time_cn = object1.optString("repayment_time_cn");
                listContent.repayment_time = object1.optString("repayment_time");
                listContent.borrow_duration_cn = object1.optString("borrow_duration_cn");
                listContent.invest_time_cn = object1.optString("invest_time_cn");
                listContent.breakday = object1.optString("breakday");

                listContent.sort_order = object1.optString("sort_order");
                listContent.capital = object1.optString("capital");
                listContent.interest = object1.optString("interest");

                list.add(listContent);
            }
            info.list = list;

            TOAST = object.optString("tips");

            return info;

        }*/
        Info info = new Info();
        Gson gson = new Gson();
        info = gson.fromJson(object.toString(),Info.class);

        TOAST = object.optString("tips");
        return info;
    }

    public static class Info {

        public Page page;


        public static class Page {
            public int nowPage;
            public int totalPages;
            public int pageSize;
            public int totalRows;
        }

        public List<ListContent> list;


        public static class ListContent {
            public String id;
            public String borrow_name;
            public String borrow_money;
            public String repayment_type;
            public String add_time;
            public String repayment_money;
            public String repayment_type_cn;
            //借款进度
            public String progress;
            public String borrow_interest_rate;
            public String repayment_time;
            public String borrow_duration;
            public String borrow_duration_cn;
            public String capital;
            public String interest;
            public String expired_money;
            public String call_fee;
            public String allneed;
            public String deadline;
            public String sort_order;
            public String total;
            public String breakday;
            public String status;
            public String dealinfo;
            public String repayment_money_all;


            //逾期投资返回的json
//            {
//                "borrow_user": "testuser1", //借入人
//                    "borrow_interest_rate": "12.00",//年利率
//                    "borrow_id": "4",//标号
//                    "borrow_name": "余钱宝第4期",//项目名称
//                    "status": null,
//                    "total": "2",总期数
//                    "sort_order": "1",
//                    "interest": "1.22",
//                    "capital": "60.70",
//                    "deadline": "1485014399",
//                    "breakday": 34//逾期天数
//            }

            //回收中的投资
//            {
//                "investor_all": "251.84",
//                    "id": "12",
//                    "borrow_id": "1",
//                    "investor_capital": "245.69",
//                    "investor_interest": "6.15",
//                    "receive_capital": "0.00",
//                    "receive_interest": "2.05",
//                    "invest_time": "1481078066",
//                    "borrow_name": "余钱宝第一期",
//                    "borrow_money": "120000.00",
//                    "borrow_interest_rate": "10.00",
//                    "borrow_duration": "3",
//                    "repayment_type": "4",
//                    "borrow_status": "6",
//                    "has_pay": "0",
//                    "borrow_user": "testuser1",
//                    "total": "3",
//                    "back": "0",
//                    "receive_money": "2.05",
//                    "unreceive_money": "245.69",
//                    "unreceive_interest": "4.10",
//                    "repayment_time_cn": "2017-01-07",
//                    "repayment_time": "1483804799",
//                    "borrow_duration_cn": "个月",
//                    "invest_time_cn": "2016-12-07"
//            }

        }
    }
}